package com.ce.pms.custservice.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.custservice.dao.IReturnVisitRecordDao;
import com.ce.pms.custservice.model.ReturnVisitRecordDO;
import com.ce.pms.custservice.vo.ReturnVisitRecordVO;
import com.sitechasia.webx.core.support.Page;

/***
 * 回访登记DaoImpl
 * @author 高嵩
 *
 */
public class ReturnVisitRecordDaoImpl extends PmsBaseDaoImpl<ReturnVisitRecordDO> implements IReturnVisitRecordDao{

	/***
	 * 功能描述: 根据ID查询回访登记 <br>
	 * @param id
	 * @return ReturnVisitRecordVO
	 * @roseuid 4943511A032C
	 * Create author:高嵩 <br>
	 * Create on:2008-12-23  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public ReturnVisitRecordDO getReturnVisitRecordByID(Long id) {
		// TODO Auto-generated method stub
		return null;
	}


    /***
     * 功能描述:  分页查询回访登记<br>
     * @param returnVisitRecordVO
     * @return Page
	 * @roseuid 49435189006D
     * Create author:高嵩 <br>
     * Create on:2008-12-23  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
	public Page queryReturnVisitRecordByPage(ReturnVisitRecordVO returnVisitRecordVO) {
		// TODO Auto-generated method stub
		Map<String,Object> paramMap = new HashMap<String,Object>();
		StringBuffer strBuf = new StringBuffer("from ReturnVisitRecordDO rvr where 1=1 ");
		if(null!=returnVisitRecordVO.getCustomerServiceEventID()){
			strBuf.append(" and rvr.customerServiceEventDO.keyword = :keyword");
			paramMap.put("keyword", returnVisitRecordVO.getCustomerServiceEventID());
		}
		 if(null!=returnVisitRecordVO.getSortStr()&& !"".equals(returnVisitRecordVO.getSortStr())){

			strBuf.append(" order by ").append(returnVisitRecordVO.getSortStr()).append(" ");
		}else{
			strBuf.append(" order by rvr.sysInfo.sysDate DESC");

		}
		return super.pagedNameQueryByPageNo(strBuf.toString(),returnVisitRecordVO.getPageNo(),returnVisitRecordVO.getPageSize(), paramMap);


	}


	   /***
	    * 功能描述: 查询回访登记列表 <br>
	    * @param returnVisitRecordVO
	    * @return List<ReturnVisitRecordVO>
		* @roseuid 4943515100BB
	    * Create author:高嵩 <br>
	    * Create on:2008-12-23  <br>
	    * Edit author:  <br>
	    * Edit on:    <br>
	    * Why:     <br>
	    */
	public List<ReturnVisitRecordDO> queryReturnVisitRecordList(ReturnVisitRecordVO returnVisitRecordVO) {
		// TODO Auto-generated method stub
		return null;
	}

	 /***
	    * 功能描述: 跟据事件ID查询回访列表 <br>
	    * @param EventId
	    * @return
	    * Create author:高嵩 <br>
	    * Create on:2009-1-13  <br>
	    * Edit author:  <br>
	    * Edit on:    <br>
	    * Why:     <br>
	    */
	   public List<ReturnVisitRecordDO> queryReturnVisitRecordByEventID(Long EventId){
		   String hql = "from ReturnVisitRecordDO rvr where rvr.customerServiceEventDO.id = ?";
		   Query query =super.createQuery(hql, new Object[]{EventId});
		   return query.list();
	   }

}
